package com.summer.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * 作者:夏天
 * qq:1205232048
 */
public class CharacterEncodingFilter implements Filter {
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    /**
     * 对所有页面进行编码过滤
     * @param req
     * @param resp
     * @param chain
     * @throws IOException
     * @throws ServletException
     */
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html");
        chain.doFilter(req,resp);
    }

    public void destroy() {

    }
}
